package com.datechange.demo.service.impl;

import com.datechange.demo.dao.CmsAttachmentDao;
import com.datechange.demo.entity.CmsAttachment;
import com.datechange.demo.service.CmsAttachmentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CmsAttachment)表服务实现类
 *
 * @author makejava
 * @since 2020-12-14 15:46:51
 */
@Service("cmsAttachmentService")
public class CmsAttachmentServiceImpl implements CmsAttachmentService {
    @Resource
    private CmsAttachmentDao cmsAttachmentDao;

    /**
     * 通过ID查询单条数据
     *
     * @param caId 主键
     * @return 实例对象
     */
    @Override
    public CmsAttachment queryById(String caId) {
        return this.cmsAttachmentDao.queryById(caId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<CmsAttachment> queryAllByLimit(int offset, int limit) {
        return this.cmsAttachmentDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param cmsAttachment 实例对象
     * @return 实例对象
     */
    @Override
    public CmsAttachment insert(CmsAttachment cmsAttachment) {
        this.cmsAttachmentDao.insert(cmsAttachment);
        return cmsAttachment;
    }

    /**
     * 修改数据
     *
     * @param cmsAttachment 实例对象
     * @return 实例对象
     */
    @Override
    public CmsAttachment update(CmsAttachment cmsAttachment) {
        this.cmsAttachmentDao.update(cmsAttachment);
        return this.queryById(cmsAttachment.getCaId());
    }

    /**
     * 通过主键删除数据
     *
     * @param caId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String caId) {
        return this.cmsAttachmentDao.deleteById(caId) > 0;
    }

    @Override
    public List<CmsAttachment> findBycaBId(String caBId) {

        return cmsAttachmentDao.findBycaBId(caBId);
    }
}